//@author A0087191Y
package net.mysoc.w111j.service.filters;

import net.mysoc.w111j.model.Category;
import net.mysoc.w111j.model.Expense;

/**
 * An {@code ExpenseFilter} matching expenses that have a given {@code Category}.
 */
public class CategoryExpenseFilter implements ExpenseFilter {
    private final Category category;

    public CategoryExpenseFilter(Category category) {
        if (category == null) {
            throw new NullPointerException("Category should not be null.");
        }
        this.category = category;
    }

    public Category getCategory() {
        return category;
    }

    @Override
    public boolean shouldSelect(Expense expense) {
        return category.equals(expense.getCategory());
    }

    @Override
    public String getDescription() {
        return category.getName();
    }
}
